package org.gap.dao;

import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import org.gap.domain.CodesPostaux;

import org.skyway.spring.util.dao.AbstractJpaDao;

import org.springframework.dao.DataAccessException;

import org.springframework.stereotype.Repository;

import org.springframework.transaction.annotation.Transactional;

/**
 * DAO to manage CodesPostaux entities.
 * 
 */
@Repository("CodesPostauxDAO")
@Transactional
public class CodesPostauxDAOImpl extends AbstractJpaDao<CodesPostaux> implements
		CodesPostauxDAO {

	/**
	 * Set of entity classes managed by this DAO.  Typically a DAO manages a single entity.
	 *
	 */
	private final static Set<Class<?>> dataTypes = new HashSet<Class<?>>(Arrays.asList(new Class<?>[] { CodesPostaux.class }));

	/**
	 * EntityManager injected by Spring for persistence unit 
	 *
	 */
	@PersistenceContext(unitName = "")
	private EntityManager entityManager;

	/**
	 * Instantiates a new CodesPostauxDAOImpl
	 *
	 */
	public CodesPostauxDAOImpl() {
		super();
	}

	/**
	 * Get the entity manager that manages persistence unit 
	 *
	 */
	public EntityManager getEntityManager() {
		return entityManager;
	}

	/**
	 * Returns the set of entity classes managed by this DAO.
	 *
	 */
	public Set<Class<?>> getTypes() {
		return dataTypes;
	}

	/**
	 * JPQL Query - findCodesPostauxByCdpNInsee
	 *
	 */
	@Transactional
	public Set<CodesPostaux> findCodesPostauxByCdpNInsee(String cdpNInsee) throws DataAccessException {

		return findCodesPostauxByCdpNInsee(cdpNInsee, -1, -1);
	}

	/**
	 * JPQL Query - findCodesPostauxByCdpNInsee
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<CodesPostaux> findCodesPostauxByCdpNInsee(String cdpNInsee, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findCodesPostauxByCdpNInsee", startResult, maxRows, cdpNInsee);
		return new LinkedHashSet<CodesPostaux>(query.getResultList());
	}

	/**
	 * JPQL Query - findCodesPostauxByCdpCodePostal
	 *
	 */
	@Transactional
	public Set<CodesPostaux> findCodesPostauxByCdpCodePostal(String cdpCodePostal) throws DataAccessException {

		return findCodesPostauxByCdpCodePostal(cdpCodePostal, -1, -1);
	}

	/**
	 * JPQL Query - findCodesPostauxByCdpCodePostal
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<CodesPostaux> findCodesPostauxByCdpCodePostal(String cdpCodePostal, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findCodesPostauxByCdpCodePostal", startResult, maxRows, cdpCodePostal);
		return new LinkedHashSet<CodesPostaux>(query.getResultList());
	}

	/**
	 * JPQL Query - findCodesPostauxByCdpParticuBureauDistrib
	 *
	 */
	@Transactional
	public Set<CodesPostaux> findCodesPostauxByCdpParticuBureauDistrib(String cdpParticuBureauDistrib) throws DataAccessException {

		return findCodesPostauxByCdpParticuBureauDistrib(cdpParticuBureauDistrib, -1, -1);
	}

	/**
	 * JPQL Query - findCodesPostauxByCdpParticuBureauDistrib
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<CodesPostaux> findCodesPostauxByCdpParticuBureauDistrib(String cdpParticuBureauDistrib, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findCodesPostauxByCdpParticuBureauDistrib", startResult, maxRows, cdpParticuBureauDistrib);
		return new LinkedHashSet<CodesPostaux>(query.getResultList());
	}

	/**
	 * JPQL Query - findCodesPostauxByCdpParticuCommuneLieuDitContaining
	 *
	 */
	@Transactional
	public Set<CodesPostaux> findCodesPostauxByCdpParticuCommuneLieuDitContaining(String cdpParticuCommuneLieuDit) throws DataAccessException {

		return findCodesPostauxByCdpParticuCommuneLieuDitContaining(cdpParticuCommuneLieuDit, -1, -1);
	}

	/**
	 * JPQL Query - findCodesPostauxByCdpParticuCommuneLieuDitContaining
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<CodesPostaux> findCodesPostauxByCdpParticuCommuneLieuDitContaining(String cdpParticuCommuneLieuDit, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findCodesPostauxByCdpParticuCommuneLieuDitContaining", startResult, maxRows, cdpParticuCommuneLieuDit);
		return new LinkedHashSet<CodesPostaux>(query.getResultList());
	}

	/**
	 * JPQL Query - findCodesPostauxByCdpCodeMiseAJourContaining
	 *
	 */
	@Transactional
	public Set<CodesPostaux> findCodesPostauxByCdpCodeMiseAJourContaining(String cdpCodeMiseAJour) throws DataAccessException {

		return findCodesPostauxByCdpCodeMiseAJourContaining(cdpCodeMiseAJour, -1, -1);
	}

	/**
	 * JPQL Query - findCodesPostauxByCdpCodeMiseAJourContaining
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<CodesPostaux> findCodesPostauxByCdpCodeMiseAJourContaining(String cdpCodeMiseAJour, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findCodesPostauxByCdpCodeMiseAJourContaining", startResult, maxRows, cdpCodeMiseAJour);
		return new LinkedHashSet<CodesPostaux>(query.getResultList());
	}

	/**
	 * JPQL Query - findCodesPostauxByCdpBureauDistributeur
	 *
	 */
	@Transactional
	public Set<CodesPostaux> findCodesPostauxByCdpBureauDistributeur(String cdpBureauDistributeur) throws DataAccessException {

		return findCodesPostauxByCdpBureauDistributeur(cdpBureauDistributeur, -1, -1);
	}

	/**
	 * JPQL Query - findCodesPostauxByCdpBureauDistributeur
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<CodesPostaux> findCodesPostauxByCdpBureauDistributeur(String cdpBureauDistributeur, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findCodesPostauxByCdpBureauDistributeur", startResult, maxRows, cdpBureauDistributeur);
		return new LinkedHashSet<CodesPostaux>(query.getResultList());
	}

	/**
	 * JPQL Query - findCodesPostauxByCdpCodePostalContaining
	 *
	 */
	@Transactional
	public Set<CodesPostaux> findCodesPostauxByCdpCodePostalContaining(String cdpCodePostal) throws DataAccessException {

		return findCodesPostauxByCdpCodePostalContaining(cdpCodePostal, -1, -1);
	}

	/**
	 * JPQL Query - findCodesPostauxByCdpCodePostalContaining
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<CodesPostaux> findCodesPostauxByCdpCodePostalContaining(String cdpCodePostal, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findCodesPostauxByCdpCodePostalContaining", startResult, maxRows, cdpCodePostal);
		return new LinkedHashSet<CodesPostaux>(query.getResultList());
	}

	/**
	 * JPQL Query - findCodesPostauxByCdpParticuCommuneLieuDit
	 *
	 */
	@Transactional
	public Set<CodesPostaux> findCodesPostauxByCdpParticuCommuneLieuDit(String cdpParticuCommuneLieuDit) throws DataAccessException {

		return findCodesPostauxByCdpParticuCommuneLieuDit(cdpParticuCommuneLieuDit, -1, -1);
	}

	/**
	 * JPQL Query - findCodesPostauxByCdpParticuCommuneLieuDit
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<CodesPostaux> findCodesPostauxByCdpParticuCommuneLieuDit(String cdpParticuCommuneLieuDit, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findCodesPostauxByCdpParticuCommuneLieuDit", startResult, maxRows, cdpParticuCommuneLieuDit);
		return new LinkedHashSet<CodesPostaux>(query.getResultList());
	}

	/**
	 * JPQL Query - findAllCodesPostauxs
	 *
	 */
	@Transactional
	public Set<CodesPostaux> findAllCodesPostauxs() throws DataAccessException {

		return findAllCodesPostauxs(-1, -1);
	}

	/**
	 * JPQL Query - findAllCodesPostauxs
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<CodesPostaux> findAllCodesPostauxs(int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findAllCodesPostauxs", startResult, maxRows);
		return new LinkedHashSet<CodesPostaux>(query.getResultList());
	}

	/**
	 * JPQL Query - findCodesPostauxByCdpBureauDistributeurContaining
	 *
	 */
	@Transactional
	public Set<CodesPostaux> findCodesPostauxByCdpBureauDistributeurContaining(String cdpBureauDistributeur) throws DataAccessException {

		return findCodesPostauxByCdpBureauDistributeurContaining(cdpBureauDistributeur, -1, -1);
	}

	/**
	 * JPQL Query - findCodesPostauxByCdpBureauDistributeurContaining
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<CodesPostaux> findCodesPostauxByCdpBureauDistributeurContaining(String cdpBureauDistributeur, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findCodesPostauxByCdpBureauDistributeurContaining", startResult, maxRows, cdpBureauDistributeur);
		return new LinkedHashSet<CodesPostaux>(query.getResultList());
	}

	/**
	 * JPQL Query - findCodesPostauxByCdpNInseeContaining
	 *
	 */
	@Transactional
	public Set<CodesPostaux> findCodesPostauxByCdpNInseeContaining(String cdpNInsee) throws DataAccessException {

		return findCodesPostauxByCdpNInseeContaining(cdpNInsee, -1, -1);
	}

	/**
	 * JPQL Query - findCodesPostauxByCdpNInseeContaining
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<CodesPostaux> findCodesPostauxByCdpNInseeContaining(String cdpNInsee, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findCodesPostauxByCdpNInseeContaining", startResult, maxRows, cdpNInsee);
		return new LinkedHashSet<CodesPostaux>(query.getResultList());
	}

	/**
	 * JPQL Query - findCodesPostauxByCdpLocaliteFiscalStandard
	 *
	 */
	@Transactional
	public Set<CodesPostaux> findCodesPostauxByCdpLocaliteFiscalStandard(Boolean cdpLocaliteFiscalStandard) throws DataAccessException {

		return findCodesPostauxByCdpLocaliteFiscalStandard(cdpLocaliteFiscalStandard, -1, -1);
	}

	/**
	 * JPQL Query - findCodesPostauxByCdpLocaliteFiscalStandard
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<CodesPostaux> findCodesPostauxByCdpLocaliteFiscalStandard(Boolean cdpLocaliteFiscalStandard, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findCodesPostauxByCdpLocaliteFiscalStandard", startResult, maxRows, cdpLocaliteFiscalStandard);
		return new LinkedHashSet<CodesPostaux>(query.getResultList());
	}

	/**
	 * JPQL Query - findCodesPostauxByPrimaryKey
	 *
	 */
	@Transactional
	public CodesPostaux findCodesPostauxByPrimaryKey(String cdpPays, String cdpCodePostal, String cdpNInsee, String cdpLocalite) throws DataAccessException {

		return findCodesPostauxByPrimaryKey(cdpPays, cdpCodePostal, cdpNInsee, cdpLocalite, -1, -1);
	}

	/**
	 * JPQL Query - findCodesPostauxByPrimaryKey
	 *
	 */

	@Transactional
	public CodesPostaux findCodesPostauxByPrimaryKey(String cdpPays, String cdpCodePostal, String cdpNInsee, String cdpLocalite, int startResult, int maxRows) throws DataAccessException {
		try {
			return executeQueryByNameSingleResult("findCodesPostauxByPrimaryKey", cdpPays, cdpCodePostal, cdpNInsee, cdpLocalite);
		} catch (NoResultException nre) {
			return null;
		}
	}

	/**
	 * JPQL Query - findCodesPostauxByCdpParticuBureauDistribContaining
	 *
	 */
	@Transactional
	public Set<CodesPostaux> findCodesPostauxByCdpParticuBureauDistribContaining(String cdpParticuBureauDistrib) throws DataAccessException {

		return findCodesPostauxByCdpParticuBureauDistribContaining(cdpParticuBureauDistrib, -1, -1);
	}

	/**
	 * JPQL Query - findCodesPostauxByCdpParticuBureauDistribContaining
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<CodesPostaux> findCodesPostauxByCdpParticuBureauDistribContaining(String cdpParticuBureauDistrib, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findCodesPostauxByCdpParticuBureauDistribContaining", startResult, maxRows, cdpParticuBureauDistrib);
		return new LinkedHashSet<CodesPostaux>(query.getResultList());
	}

	/**
	 * JPQL Query - findCodesPostauxByCdpCodeMiseAJour
	 *
	 */
	@Transactional
	public Set<CodesPostaux> findCodesPostauxByCdpCodeMiseAJour(String cdpCodeMiseAJour) throws DataAccessException {

		return findCodesPostauxByCdpCodeMiseAJour(cdpCodeMiseAJour, -1, -1);
	}

	/**
	 * JPQL Query - findCodesPostauxByCdpCodeMiseAJour
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<CodesPostaux> findCodesPostauxByCdpCodeMiseAJour(String cdpCodeMiseAJour, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findCodesPostauxByCdpCodeMiseAJour", startResult, maxRows, cdpCodeMiseAJour);
		return new LinkedHashSet<CodesPostaux>(query.getResultList());
	}

	/**
	 * JPQL Query - findCodesPostauxByCdpLocalite
	 *
	 */
	@Transactional
	public Set<CodesPostaux> findCodesPostauxByCdpLocalite(String cdpLocalite) throws DataAccessException {

		return findCodesPostauxByCdpLocalite(cdpLocalite, -1, -1);
	}

	/**
	 * JPQL Query - findCodesPostauxByCdpLocalite
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<CodesPostaux> findCodesPostauxByCdpLocalite(String cdpLocalite, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findCodesPostauxByCdpLocalite", startResult, maxRows, cdpLocalite);
		return new LinkedHashSet<CodesPostaux>(query.getResultList());
	}

	/**
	 * JPQL Query - findCodesPostauxByCdpLocaliteContaining
	 *
	 */
	@Transactional
	public Set<CodesPostaux> findCodesPostauxByCdpLocaliteContaining(String cdpLocalite) throws DataAccessException {

		return findCodesPostauxByCdpLocaliteContaining(cdpLocalite, -1, -1);
	}

	/**
	 * JPQL Query - findCodesPostauxByCdpLocaliteContaining
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<CodesPostaux> findCodesPostauxByCdpLocaliteContaining(String cdpLocalite, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findCodesPostauxByCdpLocaliteContaining", startResult, maxRows, cdpLocalite);
		return new LinkedHashSet<CodesPostaux>(query.getResultList());
	}

	/**
	 * JPQL Query - findCodesPostauxByCdpPays
	 *
	 */
	@Transactional
	public Set<CodesPostaux> findCodesPostauxByCdpPays(String cdpPays) throws DataAccessException {

		return findCodesPostauxByCdpPays(cdpPays, -1, -1);
	}

	/**
	 * JPQL Query - findCodesPostauxByCdpPays
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<CodesPostaux> findCodesPostauxByCdpPays(String cdpPays, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findCodesPostauxByCdpPays", startResult, maxRows, cdpPays);
		return new LinkedHashSet<CodesPostaux>(query.getResultList());
	}

	/**
	 * JPQL Query - findCodesPostauxByCdpPaysContaining
	 *
	 */
	@Transactional
	public Set<CodesPostaux> findCodesPostauxByCdpPaysContaining(String cdpPays) throws DataAccessException {

		return findCodesPostauxByCdpPaysContaining(cdpPays, -1, -1);
	}

	/**
	 * JPQL Query - findCodesPostauxByCdpPaysContaining
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<CodesPostaux> findCodesPostauxByCdpPaysContaining(String cdpPays, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findCodesPostauxByCdpPaysContaining", startResult, maxRows, cdpPays);
		return new LinkedHashSet<CodesPostaux>(query.getResultList());
	}

	/**
	 * Used to determine whether or not to merge the entity or persist the entity when calling Store
	 * @see store
	 * 
	 *
	 */
	public boolean canBeMerged(CodesPostaux entity) {
		return true;
	}
}
